// Copyright 2023 The Okteto Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package linguist

var (
	stignore      map[string][]byte
	defaultIgnore []byte
)

func init() {
	defaultIgnore = []byte(".git")
	// based on the list available at https://github.com/github/gitignore
	stignore = make(map[string][]byte)

	stignore[Javascript] = []byte(`.git
# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless

`)

	stignore[golang] = []byte(`.git
*.exe
*.exe~
*.dll
*.so
*.dylib

# vendor folders
vendor

# Test binary, built with go test -c
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# dlv binary
__debug_bin
`)

	stignore[Python] = []byte(`.git
# Byte-compiled / optimized / DLL files
__pycache__
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build
develop-eggs
dist
downloads
eggs
.eggs
lib
lib64
parts
sdist
var
wheels
pip-wheel-metadata
share/python-wheels
*.egg-info
.installed.cfg
*.egg
MANIFEST

# PyInstaller
#  Usually these files are written by a python script from a template
#  before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build

# PyBuilder
target

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default
ipython_config.py

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env
venv
ENV
env.bak
venv.bak

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mypy
.mypy_cache
.dmypy.json
dmypy.json

# Pyre type checker
.pyre
`)

	stignore[Gradle] = []byte(`.git
.gradle
build

# Ignore Gradle GUI config
gradle-app.setting

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

# Cache of project
.gradletasknamecache
`)

	stignore[Maven] = []byte(`.git
?
`)

	stignore[Ruby] = []byte(`.git
*.gem
*.rbc
coverage
InstalledFiles
pkg
spec/reports
spec/examples.txt
test/tmp
test/version_tmp
tmp

# Ignore Byebug command history file.
.byebug_history

## Specific to RubyMotion:
.dat*
.repl_history
build
*.bridgesupport
build-iPhoneOS
build-iPhoneSimulator

## Specific to RubyMotion (use of CocoaPods):
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# vendor/Pods/

## Documentation cache and generated files:
.yardoc
_yardoc

## Environment normalization:
vendor/bundle
lib/bundler/man

# for a library or gem, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# Gemfile.lock
# .ruby-version
# .ruby-gemset

# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
.rvmrc
`)

	stignore[Csharp] = []byte(`.git
out
bin
obj/Debug
obj/Release
core.*.*.*
`)

	stignore[Rust] = []byte(`.git
`)

}

// GetSTIgnore returns a .stignore file for the specified language
func GetSTIgnore(language string) []byte {
	l := NormalizeLanguage(language)
	if s, ok := stignore[l]; ok {
		return s
	}

	return defaultIgnore
}
